package com.thirteenClassicsServer.designPattern.策略工厂_模板方法;

import java.util.HashMap;
import java.util.Map;

import org.apache.commons.lang.StringUtils;

import com.thirteenClassicsServer.designPattern.策略工厂_模板方法.handler.Handler;

/**
 * @author wangzihao10 <wangzihao@kuaishou.com>
 * Created on 2024-08-03
 */
public class Factory {
    private static final Map<String, Handler> strategyMap = new HashMap<>();

    public static Handler getInvokeStrategy(String name) {
        return strategyMap.get(name);
    }

    public static void register(String name, Handler handler) {
        if(StringUtils.isEmpty(name) || handler == null){
            return ;
        }
        strategyMap.put(name, handler);
    }
}
